<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

    </style>
</head>

<body>

</body>
<script>
    //模拟获取 用户数据 订单数据 商品数据
    function getUser() {
        setTimeout(() => {
            let data = "用户数据"
            //调用next方法，传入数据
            iterator.next(data);
        }, 1000);
    }

    function getOrde() {
        setTimeout(() => {
            let data = "订单数据"
            iterator.next(data);
        }, 1000);
    }

    function getgoods() {
        setTimeout(() => {
            let data = "商品数据"
            iterator.next(data);
        }, 1000);
    }

    function* gen() {
        let user = yield getUser()
        console.log(user)
        let Orde = yield getOrde()
        console.log(Orde)
        let goods = yield getgoods()
        console.log(goods)
    }
    //调用生成器函数
    let iterator = gen();
    iterator.next()
</script>

</html>